﻿@* Please keep in mind that this layout view is also referenced and used by modules! *@

@{
    Layout = "_AdminRoot";
}

@if (ViewBag.RefreshPage == true)
{
    var btnId = (string)ViewBag.btnId;
    <script>
        @if (btnId.HasValue())
        {<text>
            try {
                window.parent.document.forms['@(ViewBag.formId)'].@(btnId).click();
            }
            catch (e) {
                try {
                    window.parent.document.getElementById('@(btnId)').click();
                }
                catch (e2) {
                }
            }
        </text>}

		@if (!(ViewBag.CloseWindow == false))
		{
            var popupId = (ViewBag.PopupId as string) ?? "modal-popup-shared";
			<text>window.parent.closePopup(@Html.Raw(popupId.EncodeJsString()));</text>

            @foreach (var message in Display.GetMessages())
            {
                <text>window.parent.displayNotification("@message.Message", "@message.Type.ToString().ToLower()");</text>
            }
		}
    </script>
}

<div id="page">
    <div class="canvas-blocker canvas-slidable"></div>
    <div class="page-main canvas-slidable">
        <header id="header" class="dispensable">
            <zone name="header" replace-content="true">
                <zone name="admin_navbar_before" preview-class="position-absolute"></zone>
                @await Component.InvokeAsync("AdminNavbar")
                <zone name="admin_navbar_after"></zone>
            </zone>

            <div id="breadcrumb">
                <zone name="admin_breadcrumb"></zone>
            </div>
        </header>

        <aside sm-suppress-if-empty-zone="sidebar_left" sm-preview-disabled="true" class="sidebar-left custom-scrollbar d-none d-md-block">
            @{ 
                Assets.BodyAttributes.AppendCssClass("has-left-sidebar");
            }
            <zone name="sidebar_left" preview-disabled="true"></zone>
        </aside>

        <zone name="beforemaincontent"></zone>

        <div id="content">
            <div class="cph">
                <zone name="admin_content_before"></zone>
                @RenderBody()
            </div>
            <div id="ajax-busy">
                <div class="bar"></div>
                <div class="bar"></div>
                <div class="bar"></div>
            </div>
        </div>

        <zone name="aftermaincontent"></zone>
    </div>

    <zone name="admin_content_after"></zone>
</div>

<partial name="Notifications" />